package com.mavenq.fly.business.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping(value = "redis")
public class RedisController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @GetMapping(value = "/setKey")
    public String setKey(String name) {
        redisTemplate.opsForValue().set("name", name);
        return "ok";
    }

    @GetMapping(value = "/getKey")
    public String getKey(String key) {
        String value = redisTemplate.opsForValue().get(key);
        log.info("getKey: " + value);
        return value;
    }



}
